<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
      div{
        background-color: yellow;
      }
    </style>
    <title>Document</title>
  </head>
  <body>
    <div>我是一个盒子</div>
    <script>
      document.querySelector('div').onclick=function(){
        alert('么么哒')
      }
    </script>
  </body>
</html>